package com.link2room.aeriabots.controller.inside;

import com.link2room.aeriabots.dto.param.base.WxComponentParamDto;

import com.link2room.aeriabots.facade.IWXComponentFacadeService;
import com.link2room.common.dto.result.base.BaseResultDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by LN on 2016/9/13.
 */
@Api(tags = {"微信公众号accessToken"})
@RestController
@RequestMapping("/in/OfficialAccountsTokens")
public class WxOfficialAccountsTokenInsideController {
    @Resource
    private IWXComponentFacadeService wxComponentFacadeService;

    @ApiOperation(value = "微信公众号accessToken", response = String.class)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "lhotelCode", required = false, value = "lhotelCode", dataType = "String", paramType = "query"),
    })
    @RequestMapping(method = RequestMethod.GET)
    public BaseResultDto getOfficialAccountsToken(
            @RequestParam(name = "lhotelCode", required = false) String lhotelCode
    ) throws Exception {
        WxComponentParamDto param = new WxComponentParamDto();
        param.setLhotelCode(lhotelCode);
        String token = wxComponentFacadeService.getAuthorizerAccessToken(param);
        BaseResultDto res = new BaseResultDto();
        res.setResultInfo(token);
        res.setResultCode(0);
        return res;
    }
}
